using System.Xml;
using System.Xml.Serialization;

namespace ABC.XPath.Test.Models
{
	/// <exclude/>
	[XmlRoot( "t1" )]
	public class TwoTransparentXmlFragments
	{
		private string _elem1;
		private XmlDocumentFragment _frag;
		private XmlDocumentFragment _frag2;
		private string _elem3;

		public static TwoTransparentXmlFragments Create1()
		{
			var doc = new XmlDocument();
			var ttxf = new TwoTransparentXmlFragments
			           	{
			           		_elem1 = "3",
			           		_elem3 = "4",
			           		_frag = doc.CreateDocumentFragment(),
			           		_frag2 = doc.CreateDocumentFragment()
			           	};
			ttxf._frag.AppendChild( doc.CreateElement( "sub1-1" ) ).InnerText = "1";
			ttxf._frag.AppendChild( doc.CreateElement( "sub1-2" ) ).InnerText = "2";
			ttxf._frag2.AppendChild( doc.CreateElement( "sub2" ) ).InnerText = "3";
			ttxf._frag2.AppendChild( doc.CreateElement( "sub2" ) ).InnerText = "4";
			return ttxf;
		}

		public static TwoTransparentXmlFragments Create2()
		{
			var doc = new XmlDocument();
			var ttxf = new TwoTransparentXmlFragments
			           	{
			           		_elem1 = null,
			           		_elem3 = null,
			           		_frag = doc.CreateDocumentFragment(),
			           		_frag2 = doc.CreateDocumentFragment()
			           	};
			ttxf._frag2.AppendChild( doc.CreateElement( "sub2" ) ).InnerText = "3";
			ttxf._frag2.AppendChild( doc.CreateElement( "sub2" ) ).InnerText = "4";
			return ttxf;
		}

		[XmlElement( "child1" )]
		public string Elem1
		{
			get { return _elem1; }
			set { _elem1 = value; }
		}

		[XmlAnyElement]
		public XmlDocumentFragment Frag
		{
			get { return _frag; }
			set { _frag = value; }
		}

		[XmlAnyElement( "sub2" )]
		public XmlDocumentFragment Frag2
		{
			get { return _frag2; }
			set { _frag2 = value; }
		}

		[XmlElement( "child3", Namespace=Namespaces.ABC )]
		public string Elem2
		{
			get { return _elem3; }
			set { _elem3 = value; }
		}
	}
}